package com.hhs.storage.controller;


import com.hhs.storage.bean.BaseUser;
import com.hhs.storage.bean.CarFleet;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.ResponseInfo;
import com.hhs.storage.service.CarFleetService;
import com.hhs.storage.util.SysUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hhs
 * @since 2022-12-20
 */
@RestController
@RequestMapping("/carFleet")
public class CarFleetController {
    @Autowired
    private CarFleetService carFleetService;
    @RequestMapping(value = "table")
    public Map<String, Object> getAll(CarFleet carFleet,InputParam inputParam) {
        return carFleetService.getAll(carFleet,inputParam);
    }
    @PostMapping(value = "edit")
    public Map<String, Object> addOrUpdate(CarFleet carFleet){
        return carFleetService.addOrUpdate(carFleet);
    }
    @RequestMapping(value = "dele")
    public Map<String, Object> dele(@RequestParam String id) {
        try{
            return carFleetService.dele(id);
        }catch (Exception e){
            e.printStackTrace();
            return ResponseInfo.error("业务关联，无法删除");
        }
    }
    //查询所有的车队
    @RequestMapping(value = "all")
    public Map<String, Object> listAll(InputParam inputParam) {
        return carFleetService.listAll(inputParam);
    }
}

